<?php
/**
 * StandardFormView Registration
 *
 * @version    1.0
 * @package    samples
 * @subpackage tutor
 * @author     Pablo Dall'Oglio
 * @copyright  Copyright (c) 2006-2011 Adianti Solutions Ltd. (http://www.adianti.com.br)
 * @license    http://www.adianti.com.br/framework-license
 */
class StandardFormView extends TStandardForm
{
    protected $form; // form
    
    /**
     * Class constructor
     * Creates the page and the registration form
     */
    function __construct()
    {
        parent::__construct();
        
        // defines the database
        parent::setDatabase('samples');
        
        // defines the active record
        parent::setActiveRecord('City');
        
        // creates the form
        $this->form = new TQuickForm('form_City');
        
        // create the form fields
        $id     = new TEntry('id');
        $name   = new TEntry('name');
        $id->setEditable(FALSE);
        
        // add the form fields
        $this->form->addQuickField('id', $id,  100);
        $this->form->addQuickField('name', $name,  100);

        // define the form action
        $this->form->addQuickAction('Save', new TAction(array($this, 'onSave')), 'ico_save.png');
        $this->form->addQuickAction('New',  new TAction(array($this, 'onEdit')), 'ico_new.png');
        $this->form->addQuickAction('Listing',  new TAction(array('StandardDataGridView', 'onReload')), 'ico_datagrid.gif');

        // add the form to the page
        parent::add($this->form);
    }
}
?>